package com.hgkj.cloud.base.service.impl;

import com.hgkj.cloud.base.common.PageInfo;
import com.hgkj.cloud.base.dao.TenantQuestionnairesMapper;
import com.hgkj.cloud.base.domain.TenantQuestionnaires;
import com.hgkj.cloud.base.service.TenantQuestionnairesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TenantQuestionnairesServiceImpl implements TenantQuestionnairesService {

    @Autowired
    private TenantQuestionnairesMapper tenantQuestionnairesMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return tenantQuestionnairesMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(TenantQuestionnaires record) {
        return tenantQuestionnairesMapper.insert(record);
    }

    @Override
    public int insertSelective(TenantQuestionnaires record) {
        return tenantQuestionnairesMapper.insertSelective(record);
    }

    @Override
    public TenantQuestionnaires selectByPrimaryKey(Long id) {
        return tenantQuestionnairesMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(TenantQuestionnaires record) {
        return tenantQuestionnairesMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(TenantQuestionnaires record) {
        return tenantQuestionnairesMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<Map<String, Object>> listQuestionnaires(PageInfo pi, Map<String, Object> map) {
        if(pi != null){
            map.put("currentCount", pi.getCurrentCount());
            map.put("pageSize", pi.getPageSize());
        }
        return tenantQuestionnairesMapper.listQuestionnaires(map);
    }

    @Override
    public long listQuestionnairesCount(Map<String, Object> map) {
        return tenantQuestionnairesMapper.listQuestionnairesCount(map);
    }

    @Override
    public TenantQuestionnaires findQuestionnaireById(Long id) {
        return tenantQuestionnairesMapper.findQuestionnaireById(id);
    }

    @Override
    public List<TenantQuestionnaires> findQuestionnaireByTenantId(Map<String, Object> map) {
        return tenantQuestionnairesMapper.findQuestionnaireByTenantId(map);
    }

    @Override
    public int delQuestionnaire(Long id) {
        return tenantQuestionnairesMapper.delQuestionnaire(id);
    }

    @Override
    public List<TenantQuestionnaires> findQnTaskQuestionnaires(PageInfo pi, Map<String, Object> map) {
        if(pi != null){
            map.put("currentCount", pi.getCurrentCount());
            map.put("pageSize", pi.getPageSize());
        }
        return tenantQuestionnairesMapper.findQnTaskQuestionnaires(map);
    }

    @Override
    public long findQnTaskQuestionnairesCount(Map<String, Object> map) {
        return tenantQuestionnairesMapper.findQnTaskQuestionnairesCount(map);
    }

    @Override
    public List<Map<String, Object>> listUsersByParameter(PageInfo pi, Map<String, Object> map) {
        if(pi != null){
            map.put("currentCount", pi.getCurrentCount());
            map.put("pageSize", pi.getPageSize());
        }
        return tenantQuestionnairesMapper.listUsersByParameter(map);
    }

    @Override
    public int listUsersByParameterCount(Map<String, Object> map) {
        return tenantQuestionnairesMapper.listUsersByParameterCount(map);
    }

    @Override
    public Map listAllQnTaskInfosQN(Map<String, Object> map) {
        return tenantQuestionnairesMapper.listAllQnTaskInfosQN(map);
    }

    @Override
    public List<Map<String, Object>> getAllQnList(Map<String, Object> map) {
        return tenantQuestionnairesMapper.getAllQnList(map);
    }

    @Override
    public List<Map<String, Object>> listAllTenantQuestionnaires(PageInfo pi,Map<String, Object> map,String name) {
        if(pi != null){
            map.put("currentCount", pi.getCurrentCount());
            map.put("pageSize", pi.getPageSize());
        }
        if(name !=null){
            map.put("name",name);
        }

        return tenantQuestionnairesMapper.listAllTenantQuestionnaires(map);
    }
}
